### FILE="Main.annotation"
# Copyright:	Public domain.
# Filename:	KEYRUPT_UPRUPT_FRESH_START.agc
# Purpose:	Part of the source code for Solarium build 55. This
#		is for the Command Module's (CM) Apollo Guidance
#		Computer (AGC), for Apollo 4.
# Assembler:	yaYUL --block1
# Contact:	Jim Lawton <jim DOT lawton AT gmail DOT com>
# Website:	www.ibiblio.org/apollo/index.html
# Page scans:	www.ibiblio.org/apollo/ScansForConversion/Solarium055/
# Mod history:	2009-09-15 JL	Created.

## Page 477

		BANK	4
KEYRUPT1	MASK	LOW5		# C(IN0) IN A
		TS	RUPTREG4
		TC	LODSAMPT	# TIME IS SNATCHED IN RUPT FOR NOUN 65
		CAF	PRIO33
		TC	NOVAC
		CADR	CHARIN
NOKEYBUF	XCH	RUPTREG4
		INDEX	LOCCTR
		TS	MPAC		# LEAVE 5 BIT KEY CODE IN MPAC FOR CHARIN
		TC	RESUME

## Page 478

UPRUPTB		TS	BANKRUPT
		TC	READTIME +1	# TIME IS SNATCHED IN RUPT FOR NOUN 65
		CAF	ZERO
		XCH	UPLINK		# ZERO UPLINK
		TS	KEYTEMP1
		CCS	DSPTAB +7	# TURN ON UPACT LIGHT
		TC	+2		# UPACT = BIT 11 OF DSPTAB +7
		CAF	B12-1		# SAFETY PLAY
		AD	ONE
		TS	KEYTEMP2	# MAG OF DSPTAB +7 INTO KEYTEMP2
		MASK	BIT11
		CCS	A
		TC	UPRPT1		# BIT 11 ALREADY DONE
		XCH	KEYTEMP2	# BIT 11 = 0
		AD	BIT11
		CS	A		# STORE NEGATIVELY
		XCH	DSPTAB +7
		CCS	A
		TC	INCNOUTU	# PREVIOUS CONTENTS WAS +
		NOOP			# SAFETY PLAY
UPRPT1		CAF	LOW5		# TEST FOR TRIPLE CHAR REDUNDANCY
		MASK	KEYTEMP1	# LOW5 OF WORD
		XCH	KEYTEMP1	# LOW5 INTO KEYTEMP1
		XCH	SR		# WHOLE WORD INTO SR
		TS	KEYTEMP2	# ORIGINAL SR INTO KEYTEMP2
		TC	SRGHT5
		MASK	LOW5		# MID 5
		AD	HI10
		TC	UPTEST
		TC	SRGHT5
		MASK	LOW5		# HIGH 5
		COM
		TC	UPTEST
UPOK		TC	RESTORSR	# CODE IS GOOD
		CS	ELRCODE		# IF CODE = ERROR LIGHT RESET, PUT +0
		AD	KEYTEMP1	# INTO UPLOCK (BIT2 OF STATE)
		CCS	A		# IF CODE NOT= ELR, PASS CODE ONLY IF
		TC	TSTUPLOK	# UPLOCK=0 (BIT 2 OF STATE)
ELRCODE		OCT	22
		TC	TSTUPLOK		
		CS	BIT2		# 0 INTO UPLOCK (BIT 2 OF STATE)
		MASK	UPLOCK
		TS	UPLOCK
		TC	ACCEPTUP
TSTUPLOK	CAF	BIT2
		MASK	UPLOCK
		CCS	A
		TC	RESUME		# UPLOCK = 1 (BIT2 OF STATE)
ACCEPTUP	XCH	KEYTEMP1	# UPLOCK = 0 (BIT2 OF STATE)
		TC	KEYRUPT1 +1

## Page 479

TMFAIL2		TC	RESTORSR	# CODE IS BAD
		CS	BIT2		# LOCK OUT FURTHER UPLINK ACTIVITY (BY
		MASK	UPLOCK		# PUTTING 1 INTO UPLOCK, BIT 2 OF STATE)
		AD	BIT2		# UNTIL ERROR LIGHT RESET IS SENT UP
		TS	UPLOCK		# UPLINK.
TMFAIL2		TC	TMALM
		TC	RESUME

RESTORSR	XCH	KEYTEMP2
		DOUBLE
		TS	SR
		TC	Q

TMALM		EQUALS	TMFAIL		# TM FAIL LIGHT ON (IN DOWNRUPT).

SRGHT5		CS	SR
		CS	SR
		CS	SR
		CS	SR
		CS	SR
		CS	A
		TC	Q		# DELIVERS WORD UNCOMPLEMENTED

UPTEST		AD	KEYTEMP1
		CCS	A
		TC	TMFAIL2
		TC	CCSHOLE
		TC	TMFAIL2
		TC	Q

HI10		OCT	77740
UPBANK		EQUALS	EXECBANK	# IN SAME BANK AS EXEC.

B12-1		OCT	3777

INCNOUTU	XCH	NOUT
		AD	ONE
		TS	NOUT
		INDEX	Q
UPLAST		TC	1

# UPACT IS TURNED OFF BY VBRELDSP, ALSO BY ERROR LIGHT RESET.

## Page 480

# THE RECEPTION OF A BAD CODE BY UPLINK LOCKS OUT FURTHER UPLINK ACTIVITY 
# BY PLACING A 1 INTO UPLOCK (BIT2 OF STATE). BIT9 (AND BIT11) OF TMKEYBUF
# IS SET TO 1 TO SEND AN INDICATION OF THIS SITUATION DOWN THE DOWNLINK.
# THE UPLINK INTERLOCK IS ALLOWED WHEN AN ERROR LIGHT RESET CODE IS SENT
# UP THE UPLINK, OR WHEN A FRESH START IS PERFORMED.
